package iso
{
	
	/**
	 * 绘制 Iso box 类
	 * @author StefanieKaka
	 */
	public class DrawnIsoBox extends DrawnIsoTile
	{
		/// 构造函数
		public function DrawnIsoBox(size : Number, color : uint, height : Number = 0)
		{
			super(size, color, height);
		}
		
///////////////////////////////////////////////////////////////////////////////////////////////////
// 重写函数
///////////////////////////////////////////////////////////////////////////////////////////////////	
	
		/// 绘制
		override protected function draw() : void
		{
			this.graphics.clear();
			
			var r : uint = m_color >>> 16 & 0xFF;
			var g : uint = m_color >>> 8 & 0xFF;
			var b : uint = m_color & 0xFF;
			
			var leftShadow : uint = (r * 0.5) << 16 | (g * 0.5) << 8 | (b * 0.5);
			var rightShadow : uint = (r * 0.75) << 16 | (g * 0.75) << 8 | (b * 0.75);
			
			// sy = y * 1.2247 + (x + z) * 0.5
			// 在 IsoObject 自身坐标系中, x 和 z 的值为 0
			// m_height 其实就是 iso 对象在自身的坐标中的 y 值
			var h : Number = m_height * IsoUtils.Y_CORRECT;
			
			// top
			this.graphics.beginFill(m_color);
			this.graphics.lineStyle(0, 0, 0.5);
			this.graphics.moveTo(-size, -h);
			this.graphics.lineTo(0, -size * 0.5 - h);
			this.graphics.lineTo(size, -h);
			this.graphics.lineTo(0, size * 0.5 - h);
			this.graphics.lineTo(-size, -h);
			this.graphics.endFill();
			
			// left
			this.graphics.beginFill(leftShadow);
			this.graphics.lineStyle(0, 0, 0.5);
			this.graphics.moveTo(-size, -h);
			this.graphics.lineTo(0, size * 0.5 - h);
			this.graphics.lineTo(0, size * 0.5);
			this.graphics.lineTo(-size, 0);
			this.graphics.lineTo(-size, -h);
			this.graphics.endFill();
			
			// right
			this.graphics.beginFill(rightShadow);
			this.graphics.lineStyle(0, 0, 0.5);
			this.graphics.moveTo(size, -h);
			this.graphics.lineTo(0, size * 0.5 - h);
			this.graphics.lineTo(0, size * 0.5);
			this.graphics.lineTo(size, 0);
			this.graphics.lineTo(size, -h);
			this.graphics.endFill();
		}

	}

}